package com.ldcc.report_system.component;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.ldcc.report_system.R;
import com.ldcc.report_system.util.WindowUtils;

/**
 * @author wwj[yeshengkele@outlool.com]
 * @description 自定义导航栏组件
 */
public class SystemNavigation extends LinearLayout {

    // 通知栏占位布局
    private LinearLayout notificationBar;

    // 导航栏高度布局
    private LinearLayout navigationBarLayout;
    // 导航栏文字
    private TextView navigationBarTextView;


    public SystemNavigation(Context context) {
        super(context);
    }

    public SystemNavigation(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.navigation_bar, this);
        this.navigationBarLayout = findViewById(R.id.navigation_bar_layout);
        this.navigationBarTextView = findViewById(R.id.navigation_bar_text_view);
        this.notificationBar = findViewById(R.id.notification_bar_z);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.navigation_attrs);
        this.navigationBarTextView.setText(typedArray.getString(R.styleable.navigation_attrs_name));
        typedArray.recycle();
        // 获取状态栏高度
        int statusBarHeight = WindowUtils.getStatusBarHeight();
        // 设置占位布局高度
        this.notificationBar.setLayoutParams(
                new LinearLayout.LayoutParams(
                        LayoutParams.MATCH_PARENT,
                        statusBarHeight
                )
        );
    }

    public LinearLayout getNotificationBar() {
        return notificationBar;
    }

    public void setNotificationBar(LinearLayout notificationBar) {
        this.notificationBar = notificationBar;
    }

    public LinearLayout getNavigationBarLayout() {
        return navigationBarLayout;
    }

    public void setNavigationBarLayout(LinearLayout navigationBarLayout) {
        this.navigationBarLayout = navigationBarLayout;
    }

    public TextView getNavigationBarTextView() {
        return navigationBarTextView;
    }

    public void setNavigationBarTextView(TextView navigationBarTextView) {
        this.navigationBarTextView = navigationBarTextView;
    }
}
